package proyecto;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author
 */

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;

/**
  * Class printWay
  *
  * @author Sergio Damián Delgado González
  * @author Javi Abella Gea
  * @version 2.0
  */
public class printWay {

	private File outputfile;
	//private BufferedImage img;
	private Color colorAux;
	int pass;
	
	/** Image format **/
	private String formato;
	
	/** directory Route **/
	private String ruta = "solvedMaps/";
	
	/** way size **/
	private int waySize;
	
	private int changeColor;
	
	private static int i = 0;
	
	public printWay(ArrayList<Pair> par, File input, String mapName) throws IOException{
         
    	//System.out.println("Dentro de printWay");
		formato = mapName.substring(mapName.length()-3, mapName.length());
		System.out.println(ruta+mapName.substring( 9, mapName.length()-4)+"_Sol"+i+"."+formato);
		outputfile = new File(ruta+mapName.substring( 9, mapName.length()-4)+"_Sol"+i+"."+formato);
         
		BufferedImage img = ImageIO.read(input);
		
		colorAux= new Color(0,255,0);
		pass= colorAux.getRGB();
		
		System.out.println();
		waySize = par.size();
		System.out.println( waySize );
		if (waySize > 400){
			changeColor = 5;
		}
		else{
			changeColor = 0;
		}
		for(int i=0; i< waySize ;i++){
			colorAux = new Color(0, 255-i/(2+changeColor), 0);
			pass = colorAux.getRGB();
			img.setRGB(par.get(i).getFirst(), par.get(i).getSecond(), pass);
		}
		  
		ImageIO.write(img, "png", outputfile);
		++i;
	}
}
